'use strict';
angular.module('app').controller('positionCtrl',['$timeout','$q','$http','$state','$scope','$catch',function($timeout,$q,$http,$state,$scope,$catch){
    $scope.isLogin = false;
    function getPosition(){
    	var def = $q.defer();
    	 $http.get('/data/position.json?id='+$state.params.id).then(function onSuccess(resp){
	       $scope.position = resp.data;
	       def.resolve(resp);
	    }).catch(function onError(resp){
	        def.reject(resp);
	    });
	    return def.promise;
    }
    function getCompany(id){
    	$http.get('/data/company.json?id='+id).then(function onSuccess(resp){
	       $scope.company = resp.data;
	    });
    }
   getPosition().then(function(obj){
   	//这是正常情况下的def.resolve()执行的
   	 getCompany(obj.companyId);
   },function(obj){
   	//这是异常情况下的def.reject()执行的
   });
   $timeout(function(){
      console.log(1);
   },1000);
  
}]);